package com.google.sky.register;

import com.google.sky.MoveResolver;
import com.google.sky.domain.MoveResolverMeta;
import com.google.sky.util.ImplementationsFinder;
import org.springframework.beans.factory.annotation.Value;

import java.util.List;

/**
 * @author: sk_y
 */
public class SettingsImpl implements Settings {
    private int h;
    private int w;

    private List<MoveResolverMeta> resolverList;

    @Value("${upload.location}")
    private String uploadPath;


    public void setHeight(int h) {
        this.h = h;
    }

    public void setWidth(int w) {
        this.w = w;
    }

    @Override
    public int getWidth() {
        return 0;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public int getHeight() {
        return 0;  //To change body of implemented methods use File | Settings | File Templates.
    }

    public String getUploadPath() {
        return uploadPath;
    }

    public MoveResolver getResolverById(int id) {
        if (resolverList == null) {
            resolverList = ImplementationsFinder.findImplementations(uploadPath);
        }
        if (resolverList.size() <= id) {
            return null;
        }
        return resolverList.get(id).getMoveResolver();
    }


}
